package server2;

import server2.mapper.mapperHost;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ThreadPoolExecutor;

public class serverSocket extends Thread{
    Integer port;
    mapperHost host;
    public serverSocket(Integer port, mapperHost host) {
        this.port = port;
        this.host = host;
    }

    @Override
    public void run() {
        ServerSocket serverSocket = null;
        try {
            serverSocket = new ServerSocket(port);

        while (true) {
            Socket socket = serverSocket.accept();
            RequestProcessor requestProcessor = new RequestProcessor(socket, host);
            ThreadPoolExecutor threadPoolExecutor = threadPool.getthreadPoolExecutor();
            threadPoolExecutor.execute(requestProcessor);
        }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
